#此文件的作用在于把改变矩阵维度，把每八行数据转成一行

import csv
import numpy as np
inputpath = './test_feature.csv'
outputpath = './test_feature_deal2.csv'
#读取csv文件成矩阵，运用numpy的loadtxt
def read_csv():
    f1 = open(inputpath,'r')
    feature = np.loadtxt(f1,delimiter=',',skiprows=0)
    feature_matrix =np.array(feature)
    return(feature_matrix)

#转换矩阵维度
def convert_matrix(matrix):
    f2= open(outputpath,'w',newline='')
    writer = csv.writer(f2)
    #这里的设置的不对
    i=0
    while i< 7290:
        new_matrix = matrix[i:i+8]
        new_matrix = new_matrix.reshape(48, order='C')
        writer.writerow(new_matrix)
        i+=8

if __name__ == '__main__':
    feature_matrix = read_csv()
    convert_matrix(feature_matrix)
